package models

import (
	"encoding/xml"
)

type Registration struct {
	User        string `xml:"user"`
	Contact     string `xml:"contact"`
	Agent       string `xml:"agent"`
	NetworkIP   string `xml:"network-ip"`
	NetworkPort string `xml:"network-port"`
}

func GetRegistrations() []Registration {
	var regs = make([]Registration, 0)

	var rsp string = GetXmlStatusProfileInternalReg()
	body := []byte(rsp)

	profile := Profile{}
	err := xml.Unmarshal(body, &profile)
	if err != nil {
		return regs
	}

	for _, reg := range profile.Registrations {
		regs = append(regs, reg)
	}

	return regs
}

type Profile struct {
	XMLName       xml.Name       `xml:"profile"`
	Registrations []Registration `xml:"registrations>registration"`
}
